
*	************************************************************************
* 	File-Name: 		ESD_2013_Patents_replication.do
*	Date:  			4 February 2013
*	Authors: 		Patrick Bayer, Lindsay Dolan, and Johannes Urpelainen
*	Journal:		Energy for Sustainable Development
* 	Paper:			External Sources of Clean Technology: Evidence from the Clean Development Mechanism
*
*	Data Used:  	Patents.dta	
*	Purpose:   		.do file for replication
*	Software:		Stata IC 12.1
*	Machine:		WINDOWS 7
*
*	************************************************************************

clear all

* NB: Please place .do file and data in the same folder
use "./Patents.dta"

set more off, permanently


*	************************************************************************
*	(I) MAIN TEXT
*	************************************************************************

*	************************************************************************
*	1. Summary statistics
*	************************************************************************

quietly: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t, fe
estpost summarize renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 if e(sample)


*	************************************************************************
*	2. Correlation matrics
*	************************************************************************

quietly: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t, fe
estpost correlate renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 if e(sample), matrix


*	************************************************************************
*	3. Main models
*	************************************************************************

eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t, fe

*	************************************************************************
*	4. Interaction models
*	************************************************************************

eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd inter1 africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd inter2 africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd inter3 africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd inter4 africa asia americas t, fe


*	************************************************************************
*	5. Industry models
*	************************************************************************

eststo clear
eststo: xtnbreg wind L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t, fe
eststo: xtnbreg solar L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t, fe
eststo: xtnbreg hydromarine L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t, fe


*	************************************************************************
*	(II) APPENDIX
*	************************************************************************

*	************************************************************************
*	A2 -- Robustness: Excluding Regions (Tables A1-A5)
*	************************************************************************

* Without African projects (Table A1)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if africa==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if africa==0 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if africa == 0 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if africa==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if africa==0, fe


* Without Asian projects (Table A2)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if asia==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if asia==0 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if asia == 0 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if asia==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if asia==0, fe


* Without Americas projects (Table A3)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if americas==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if americas==0 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if americas == 0 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if americas==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if americas==0, fe


* Without European projects (Table A4)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if europe==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if europe==0 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if europe == 0 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if europe==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if europe==0, fe


* Without Oceanian projects (Table A5)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if oceania==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if oceania==0 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if oceania== 0 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if oceania==0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if oceania==0, fe



*	************************************************************************
*	A3 -- Robustness: Excluding Zero-Patent Counts and Outliers (Tables A6-A8)
*	************************************************************************

* Excluse zero patents aka "fake zero inflation model" (Table A6)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents>0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents>0 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents>0 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if renew_patents>0, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if renew_patents>0, fe


* Exclude outliers (Table A7)
eststo clear
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents<55.1667, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents<55.1667 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents<55.1667 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if renew_patents<55.1667, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if renew_patents<55.1667, fe


* Exclude zero patents and outliers (Table A8)
eststo clear
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents>0 & renew_patents<55.1667, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents>0 & renew_patents<55.1667 & year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t if renew_patents>0 & renew_patents<55.1667 & year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas t if renew_patents>0 & renew_patents<55.1667, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t if renew_patents>0 & renew_patents<55.1667, fe


*	************************************************************************
*	A4 -- Robustness: Controlling for Country Openness, Domestic, and International Institutions (Tables A9-A11)
*	************************************************************************

* Model with control for county openness (Table A9)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1kaopen L1KOFindex, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1kaopen L1KOFindex if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1kaopen L1KOFindex if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas L1kaopen L1KOFindex t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas L1kaopen L1KOFindex t, fe

* Model with control for domestic institutions (Table A10)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1checks L1icrg_investment_profile, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1checks L1icrg_investment_profile if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1checks L1icrg_investment_profile if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas L1checks L1icrg_investment_profile t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas L1checks L1icrg_investment_profile t, fe

* Model with control for international institutions (Table A11)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1eu L1kyoto, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1eu L1kyoto if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas t L1eu L1kyoto if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas L1eu L1kyoto t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas L1eu L1kyoto t, fe


*	************************************************************************
*	A5 -- Robustness: Controlling for Learning (Table A12)
*	************************************************************************

eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas cumCDMcount1000 t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas cumCDMcount1000 t if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd africa asia americas cumCDMcount1000 t if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp africa asia americas cumCDMcount1000 t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas cumCDMcount1000 t, fe

*	************************************************************************
*	A6 -- Robustness: Controlling for Size of the Electricity Sector (Table A13)
*	************************************************************************

eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1elec_con_wdi_log africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1elec_con_wdi_log africa asia americas t if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1elec_con_wdi_log africa asia americas t if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1elec_con_wdi_log africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1elec_con_wdi_log L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t, fe


*	************************************************************************
*	A7 -- Robustness: Controlling for Education Expenditures and Skilled Labor (Tables A14-A15)
*	************************************************************************

* Model with control for education expenditures (Table A14)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1logeducexp africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1logeducexp africa asia americas t if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1logeducexp africa asia americas t if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1logeducexp L1loggdp africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1oecd L1logeducexp L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t, fe

* Model with control for tertiary education (Table A15)
eststo clear 
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1logeducexp L1oecd L1tertiaryeduc africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1logeducexp L1oecd L1tertiaryeduc africa asia americas t if year > 1994, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1logeducexp L1oecd L1tertiaryeduc africa asia americas t if year < 2008, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1logeducexp L1oecd L1tertiaryeduc L1loggdp africa asia americas t, fe
eststo: xtnbreg renew_patents L1oil_price L1renew_cap_log L1democracy L1corrupt L1logeducexp L1oecd L1tertiaryeduc L1loggdp L1fdi_inflow L1trade L1urban L1pm10 africa asia americas t, fe


